package stream;

import io.r2dbc.spi.Parameter;

import java.util.function.*;

public class LamdaApp {
    public static void main(String[] args) {
        Consumer consumer1=s-> System.out.println(s);
        Consumer<String> consumer2=(String s)-> System.out.println(s);
        consumer2.accept("abc");

        Function<String,Integer> fn1=(String s)->s.length();
        System.out.println(fn1.apply("abc"));

        Predicate<Integer> predicate=(Integer m)->m.intValue()>0;
        System.out.println(predicate.test(20));

        Supplier<Double> supplier=()-> Math.random();
        System.out.println(supplier.get());

        BiFunction<Integer,Integer,Integer> biFunction=(min,max)->(int)((max-min)*Math.random())+min;
        for (int i = 0; i < 10; i++) {
            System.out.println(biFunction.apply(1, 100));
        }

        Consumer consumerx=s-> System.out.println("hello:"+s);
        print(new String[]{"abc","cde"},consumerx);
        print(new String[]{"abc","cde"},System.out::println);


    }

    public static void print(String[] as ,Consumer<String> consumer){
        for (int i = 0; i < as.length; i++) {
            consumer.accept(as[i]);
        }
    }


}
